package com.talkyun.openx.ocean.base;

import com.talkyun.openx.interceptor.AbstractSpringAntMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class AbstractHttpInterceptor extends AbstractSpringAntMatcher implements HttpInterceptor {
    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void doGetIn(HttpRequest req) {
        if (this.isMatched(req.getUrl())) {
            doAnyHttpRequest(req);
        }
    }

    @Override
    public void doGetOut(HttpRequest req) {
        if (this.isMatched(req.getUrl())) {
            doAnyHttpRequest(req);
        }
    }

    @Override
    public void doPostIn(HttpRequest req) {
        this.doGetIn(req);
    }

    @Override
    public void doPostOut(HttpRequest req) {
        this.doGetOut(req);
    }

    protected abstract void doAnyHttpRequest(HttpRequest req);
}